<?php


namespace app\api\model;


use app\lib\exception\CategoryException;

class Category extends BaseModel
{
    protected $hidden = ['delete_time','update_time'];
    public function topicImg(){
        return $this->belongsTo('Image','topic_img_id','id');
    }
//    public  function productItems(){
//        return $this->hasMany('Product','category_id','id');
//    }
     public static function getCategory(){
//        $category = self::with('topicImg,productItems')->select();
         $category = self::all([],'topicImg,productItems');

         if ($category->isEmpty()){

            throw  new  CategoryException();
        }
        return $category;
    }

}